package com.study_online.service.Impl;

import com.study_online.domain.Barrage;
import com.study_online.mapper.BarrageMapper;
import com.study_online.service.BarrageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service("barrageServiceimpl")
public class BarrageServiceimpl implements BarrageService {
    @Autowired
    private BarrageMapper barrageMapper;
    @Override
    public List<String> findAll() {
        return barrageMapper.findAll();
    }

    @Override
    public void save(String userid,String videoid,String message) {
        Barrage barrage = new Barrage();
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String sendtime = sdf.format(date);
        barrage.setUserid(Integer.parseInt(userid));
        barrage.setVideoid(Integer.parseInt(videoid));
        barrage.setBrmessage(message);
        barrage.setAddtime(sendtime);
        barrageMapper.save(barrage);
    }
}
